cmake_minimum_required(VERSION 3.18)

project(test_singleton_in_static C CXX)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_compile_options("-fvisibility=hidden")

add_library(static STATIC static.cpp)
add_library(dynamic1 SHARED dynamic1.cpp)
target_link_libraries(dynamic1 PRIVATE static)
add_library(dynamic2 SHARED dynamic2.cpp)
target_link_libraries(dynamic2 PRIVATE static)

add_executable(main main.cpp)
target_link_libraries(main PRIVATE dynamic1 dynamic2 static)